package com.hong.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hong.common.controller.BaseController;
import com.hong.common.util.ShiroUtil;
import com.hong.entity.SysUser;
import com.hong.entity.vo.TreeMenu;
import com.hong.service.ISysMenuService;

@Controller
public class IndexController extends BaseController {

	@Autowired
	private ISysMenuService sysMenuService;

	/**
	 * 首页内容跳转
	 * 
	 * @return
	 */
	@RequestMapping("/index")
	public String index() {
		// 保存登录信息
		SysUser currentUser = ShiroUtil.getSessionUser();
		currentUser.setPassword("");
		ShiroUtil.setSessionAttribute("currentUser", currentUser);
		// 获取当前用户的菜单
		List<TreeMenu> treeMenus = sysMenuService.selectTreeMenuByUserId(currentUser.getId());
		ShiroUtil.setSessionAttribute("treeMenus", treeMenus);
		return "index";
	}

	/**
	 * 无权限跳转
	 * 
	 * @return
	 */
	@RequestMapping("/unauth")
	public String unauth() {
		return "error/403";
	}
}
